package org.saratogaschools.edd.firefighter.client.util;

import java.util.List;

import org.saratogaschools.edd.firefighter.shared.FireFighterServiceAsync;
import org.saratogaschools.edd.firefighter.shared.model.Department;

import com.google.gwt.user.client.rpc.AsyncCallback;
import com.google.gwt.view.client.AsyncDataProvider;
import com.google.gwt.view.client.HasData;

public class DepartmentDataProvider extends AsyncDataProvider<Department> {
	
	private FireFighterServiceAsync service;
	
	public DepartmentDataProvider(FireFighterServiceAsync service) {
		this.service = service;
	}

	@Override
	protected void onRangeChanged(final HasData<Department> display) {
		service.getDepartmentList(new AsyncCallback<List<Department>>() {
			public void onSuccess(List<Department> departments) {
				updateRowCount(departments.size(), true);
				updateRowData(0, departments);
			}
			public void onFailure(Throwable caught) {
				
			}
		});
		
		
	}

}
